package com.htfyun.eink.pw.draw.pen.epd.data;

import java.util.ArrayList;
import java.util.List;

public class PenHelper {

    public static List<NeoRenderPoint> generateStrokePoints(NeoRenderPoint p0, NeoRenderPoint p1) {
        List<NeoRenderPoint> list = new ArrayList<>();

        float diff = p1.size - p0.size;
        int diffInt = (int) diff;
        if (diffInt == 0) {
            return list;
        }
        diffInt = diffInt + 1;

        float sizeStep = diff / diffInt;
        float xStep = (p1.x - p0.x) / diffInt;
        float yStep = (p1.y - p0.y) / diffInt;

        float sizeStart = p0.size;
        float xStart = p0.x;
        float yStart = p0.y;
        for (int i = 1; i < diffInt; i++) {
            NeoRenderPoint point = new NeoRenderPoint();
            point.size = sizeStart + (i * sizeStep);
            point.x = xStart + (i * xStep);
            point.y = yStart + (i * yStep);

            list.add(point);
        }


        return list;
    }
}
